<%--
  Created by IntelliJ IDEA.
  User: Asus
  Date: 2022/4/13
  Time: 11:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>ajaxTest</title>
    <script type="text/javascript" src="js/jquery-1.11.1.js"></script>
    <script type="text/javascript">
      $(function(){
        $("#uid").blur(function(){
          var uid = $(this).val();
          $.post("/getuid","uid="+uid,function(rs){
            rs = eval("("+rs+")");
            $("#result").html(rs.idInfo);
            if("用户名已重复"==rs.idInfo){
              $("#result").attr("style","color:red");
            }else{
              $("#result").attr("style","color:green");
            }
            $("#uname").val(rs.userName);
            $("#uCity").val(rs.userCity);
          });
        });
      })
    </script>
  </head>
  <body>
    <h2>用户名有效性验证 和 用户数据的自动填充</h2>
    userId:<input type="text" id="uid">
    <span id="result"></span><br>
    userName:<input type="text" id="uname"><br>
    userCity:<input type="text" id="uCity">
  </body>
</html>
